home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pistol.zip / PISTOL.C < prev    next >
Text File  |  1987-08-20  |  4KB  |  136 lines

  1. /*********************************************************/
  2. /*                             */
  3. /* PISTOL-Portably Implemented Stack Oriented Language     */
  4. /*            Version 1.3             */
  5. /* (C) 1982 by    Ernest E. Bergmann             */
  6. /*        Physics, Building #16             */
  7. /*        Lehigh Univerisity             */
  8. /*        Bethlehem, Pa. 18015             */
  9. /*                             */
  10. /* Permission is hereby granted for all reproduction and */
  11. /* distribution of this material provided this notice is */
  12. /* is included.                         */
  13. /*                             */
  14. /*********************************************************/
  15.  
  16. /* main pistol module, February 1982 */
  17.  
  18. #include "bdscio.h"
  19. #include "pistol.h"
  20.  
  21. main()
  22. {    for (temp=0; temp<RAMSIZE; temp++)
  23.         {ram[temp].in=10000;};
  24.     ram[-57].in=MAXLINNO;
  25.     ram[-56].in=CHKLMT;
  26.     ram[-55].pw=nram;
  27.     ram[-54].pc=strings;
  28.     ram[-53].in=FALS;    /*bell*/
  29.     ram[-52].in=FALS;    /* abort patch */
  30.     ram[-51].in=FALS;    /* conversion patch */
  31.     ram[-50].in=FALS;    /* standard prompt */
  32.     ram[-49].pc=strings+STRINGSSIZE;
  33.     ram[-48].pw=&ram[VBASE];
  34.     ram[-47].in=VSIZE;
  35.     ram[-46].in=CSIZE;
  36.     ram[-45].in=LSIZE;
  37.     ram[-44].in=RSIZE;
  38.     ram[-43].in=SSIZE;
  39.     ram[-42].pc=strings+2800;
  40.     ram[-41].pw=&ram[RAMSIZE-250];
  41.     ram[-40].pw=&ram[RAMSIZE];
  42.     ram[-39].in=MAXORD;
  43.     ram[-38].in=MAXINT;
  44.     /*ram[-37]=*/
  45.     ram[-36].in=VERSION;
  46.     ram[-34].in=0;
  47.     ram[-33].in=FALS;    /* nil link for PISTOL< */
  48.         /* initializing file status */
  49.     ram[-27].in=8;    /* init tabsize */
  50.     ram[-25].in=ABRT;    /* init endcase to abort */
  51.     ram[-24].in=0;    /*reset column location */
  52.     ram[-23].in=TERMWIDTH;
  53.     ram[-21].in=TERMLENGTH;
  54.     ram[-20].in=FALS;    /* compile-end-patch */
  55.     ram[-19].in=FALS;    /* init TRACE off */
  56.     ram[-17].in=TRU;    /* raise on */
  57.     ram[-13].in=FALS;    /* echo off */
  58.     ram[-6].pw=&ram[-34];
  59.     ram[-5].pc=&strings[CHKLMT+2];
  60.     ram[-4].pc=ram[-5].pc;
  61.     ram[-3].pc=&ram[80];
  62.  
  63.     divby0=addstring(16,"DIVISION BY ZERO");
  64.     nopen=addstring(20,"*** FILE NOT OPENED*");
  65.     feof=addstring(20,"*** EOF ENCOUNTERED*");
  66.     id=addstring(18,"*** PISTOL 1.3 ***");
  67.     synt=addstring(20,"*** SYNTAX ERROR ***");
  68.     ovflo=addstring(19,"** STACK OVERFLOW *");
  69.     undflo=addstring(19,"* STACK UNDERFLOW *");
  70.     redef=addstring(16,"---redefining---");
  71.  
  72.     init();    /*contains penter and fills farray */
  73.  
  74.     ram[-1].in=10;    /* DECIMAL MODE :*/
  75.     strings[0]='X';
  76.  
  77.     ram[-31].in=1;    /* edout */
  78.     ram[-30].in=-1;    /* edin */
  79.     ram[-29].in=-1;    /* ldfil1 */
  80.     namein[0]=namout[0]=listnamef[0]=ram[-12].in=FALS;
  81.  
  82.     abort();    /* initialize return point */
  83.     /*reseting stacks returns i/o to tty: produces signon*/
  84.     ip=&ram;    /*so ram[ip] is in range*/
  85.     ram[-35].in=FALS;
  86.     ram[-32].pw=&ram[VBASE];
  87.     ram[VBASE].pw=&ram[-34];
  88.     ram[-6].pw=&ram[-34];
  89.     stkptr=0;
  90.     rptr=-1;
  91.     cptr=0;
  92.     lptr=0;
  93.     strings[1]='\0';
  94.     ram[-11].in=FALS;
  95.     ram[-14].in=TRU;
  96.     if (listname[0]=='\0') ram[-12].in=FALS;
  97.     /*turns off listing if no listfile is open*/
  98.     message(id);
  99.     /* ifcr */
  100.     if (ram[-24].in) carret();
  101.     ram[-19].in=FALS;    /* turn off trace */
  102.     if (ram[-52].pw) interpret(ram[-52].pw);
  103.     /* user supplied supplement to ABORT */
  104.     goto L99;
  105.     do{    ram[-2].pw=&ram[COMPBUF];
  106.         do compline(); while(strings[1]);
  107.         compile(PSEMICOLON);
  108.  
  109.         if(ram[-20].pw) interpret(ram[-20].pw);
  110.         if(ram[-14].in&&(!ram[-11].in||ram[-13].in))
  111.             ram[-24].in=ram[-22].in=FALS;
  112.         interpret(&ram[COMPBUF]);
  113.  
  114. L99:        ram[-4].pc=ram[-5].pc;
  115.     }
  116.     while( !ram[-35].in );
  117.     
  118.     printf("\nPISTOL NORMAL EXIT\n");
  119.     if(listname[0]) closout(list);
  120.     if(namout[0]) closout(edout);
  121.  
  122.     exit(); /*files need to be flushed and closed */
  123. }
  124.  
  125. closout(iobuf)
  126. char *iobuf;
  127. {    putc(CPMEOF,iobuf);
  128.     fflush(iobuf); fclose(iobuf);
  129. }
  130. ram[-32].pw=&ram[VBASE];
  131.     ram[VBASE].pw=&ram[-34];
  132.     ram[-6].pw=&ram[-34];
  133.     stkptr=0;
  134.     rptr=-1;
  135.     cptr=0;
  136.     l